from django.conf.urls import url
from django.urls import path, include

from rest_framework.routers import DefaultRouter

from plantform.views import (PlantformDataSourceViewSet,
                                  PlantformOutDataSourceViewSet,
                                  PlantformConfigViewSet,
                                  PlantformTaskViewSet,
                                  FeaturesAndMLConfigViewSet,
                                  TaskStartViewSet, DocIndexViewSet)


router = DefaultRouter()
router.register(r'data_source', PlantformDataSourceViewSet, base_name='plantform')
router.register(r'out_source', PlantformOutDataSourceViewSet, base_name='plantform')
router.register(r'ml_config', PlantformConfigViewSet, base_name='plantform')
router.register(r'task', PlantformTaskViewSet, base_name='plantform')
router.register(r'feature_ml_config', FeaturesAndMLConfigViewSet, base_name='plantform')

start_task = TaskStartViewSet.as_view({"post":"start_task"})
get_exec_results = TaskStartViewSet.as_view({"get":"get_exec_data"})
get_report_results = TaskStartViewSet.as_view({"get":"get_report_info"})
get_docs = DocIndexViewSet.as_view({"get":"get_all_index"})

urlpatterns = [
    path('', include(router.urls)),
    url(r'^start_task/$', start_task, name='start-task'),
    url(r'^get_exec_results/(?P<task_id>[0-9]+)$', get_exec_results, name='get_exec_results'),
    url(r'^get_report_info/(?P<task_id>[0-9]+)$', get_report_results, name='get_report_results'),
    url(r'^get_docs/$', get_docs, name='get_docs'),
]
